<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="../templates/template.xhtml">

	<ui:define name="title">
	 	User Browser
	</ui:define>

	<ui:param name="page" value="adminConsole" /> 

	<ui:define name="header">
		<ui:include src="/secure/header.xhtml" /> 
	</ui:define>

	<ui:define name="menu">
		<div align="center">
			<h:form id="mennuForm" >
			<br />
			<br />
			<h:commandButton value="Back" action="#{userBrowser.back}" styleClass="buttonClass" />
			<br />
			<br />
			</h:form>
		</div>
	</ui:define>

	<ui:define name="body">
		<h:form>
			<br /> 
			<div class="grayBox"> 
				<p class="descriptiveText"> The user browser allows administrators 
				the ability to view all users of the system. They may also add/edit/delete users. </p>
			</div>
			<br />
			<div><center><span class="descriptiveText">CMS used by <h:outputText value="#{court.name}"></h:outputText> is </span><b><h:outputText id="cmsName" value="#{court.cmsName}"></h:outputText></b></center></div> 
			<div class="allPeopleHolder"> 
			<h:dataTable id="allPeople" value="#{userBrowser.allPeople}"
				var="rowVar" 
				styleClass="iCubed" 
				width="80%" >
				<h:column>
					<f:facet name="header">
						<h:outputText id="userId" value="Username" />
					</f:facet>
					<h:commandLink value="#{rowVar.userId}" action="#{userBrowser.viewDetails}">
						<f:param name="personUuid" value="#{rowVar}" binding="#{userBrowser.clickedPerson}" /> 
					</h:commandLink> 
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText id="loginAs" value="LoginAs" />
					</f:facet>
					<h:commandLink value="#{rowVar.userId}" action="#{userBrowser.masquarade}">
						<f:param name="personUuid" value="#{rowVar}" binding="#{userBrowser.clickedPerson}" /> 
					</h:commandLink> 
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText id="firstName" value="Name" />
					</f:facet>
					<h:outputText value="#{rowVar.firstName} #{rowVar.lastName}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText id="roleName" value="Role" />
					</f:facet>
					<h:outputText value="#{rowVar.roles[0].role}" />
				</h:column>
				<h:column>
					<f:facet name="header">
						<h:outputText id="cvCommand" value="CV Number Box"/>	
					</f:facet>
					
					<h:commandLink action="#{userBrowser.toggleCvNumber}" rendered="${rowVar.roles[0].role == 'agent'}">
						<f:param name="personUuid" value="#{rowVar}" binding="#{userBrowser.clickedPerson}"/>
						<h:outputText value="OFF" rendered="#{!rowVar.setCivilActionNumber}"/>
						<h:outputText value="ON" rendered="#{rowVar.setCivilActionNumber}"/>
					</h:commandLink>
				</h:column>				
				<h:column>
					<f:facet name="header">
						<h:outputText id="cdCommand" value="Court Date Box"/>	
					</f:facet>
					<h:commandLink action="#{userBrowser.toggleCourtDate}" rendered="${rowVar.roles[0].role == 'agent'}">
						<f:param name="personUuid" value="#{rowVar}" binding="#{userBrowser.clickedPerson}"/>
						<h:outputText value="OFF" rendered="#{!rowVar.setCourtDate}"/>
						<h:outputText value="ON" rendered="#{rowVar.setCourtDate}"/>
					</h:commandLink>
				</h:column>	
			</h:dataTable>
			</div>
			<br />
		</h:form>
	</ui:define>

</ui:composition>

</html>
